package com.hualude.roadsign.controller;

import com.hualude.roadsign.dto.DTRequestDto;
import com.hualude.roadsign.dto.DTResponseDto;
import com.hualude.roadsign.dto.JsonMsgDto;
import com.hualude.roadsign.service.RoadLineFaultHandleService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * Created by ding on 2017/8/14.
 */
@Controller
@RequestMapping("/rds_roadLineFaultHandle")
public class RoadLineFaultHandleController {
    @Resource
    private RoadLineFaultHandleService roadLineFaultHandleService;


    @RequestMapping(value = "/getRoadLineFaultHandle4DT")
    @ResponseBody
    public DTResponseDto getRoadLineFaultHandle4DT(DTRequestDto dtRequestDto, String actorIds , Integer orgId, Integer maintenanceStatus) {
        DTResponseDto dtResponseDto = new DTResponseDto();
        try {
            dtResponseDto = roadLineFaultHandleService.getRoadLineFaultHandle4DT(dtRequestDto,actorIds, orgId,maintenanceStatus);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return dtResponseDto;
    }

    @RequestMapping("/addRoadLineMaintenanceContent")
    @ResponseBody
    public JsonMsgDto addRoadLineMaintenanceContent(Integer roadLineFaultId, String roadLineMaintenanceContent) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(roadLineFaultHandleService.addRoadLineMaintenanceContent(roadLineFaultId, roadLineMaintenanceContent));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }

    @RequestMapping("/finishRoadLineMaintenance")
    @ResponseBody
    public JsonMsgDto finishRoadLineMaintenance(String roadLineMaintenancePhoto,Integer roadLineMaintainerId,String roadLineMaintenanceTime,String roadLineMaintenanceExplain,Integer roadLineFaultId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(roadLineFaultHandleService.finishRoadLineMaintenance(roadLineMaintenancePhoto,roadLineMaintainerId,roadLineMaintenanceTime,roadLineMaintenanceExplain,roadLineFaultId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }

    @RequestMapping("/getRoadLineFaultHandleList4App")
    @ResponseBody
    public JsonMsgDto getRoadLineFaultHandleList4App(Integer orgId,Integer maintenanceStatus,String actorIds,Integer count,Integer size) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(roadLineFaultHandleService.getRoadLineFaultHandleList4App(orgId, maintenanceStatus, actorIds, count, size));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);

        }
        return jsonMsgDto;
    }

    @RequestMapping("/getRoadLineReceiptInfo4App")
    @ResponseBody
    public JsonMsgDto getRoadLineReceiptInfo4App(Integer roadLineFaultId) {
        JsonMsgDto jsonMsgDto = new JsonMsgDto();
        try {
            jsonMsgDto.setJsonData(roadLineFaultHandleService.getRoadLineReceiptInfo4App(roadLineFaultId));
            jsonMsgDto.setIsSuccess(true);
        } catch (Exception e) {
            e.printStackTrace();
            jsonMsgDto.setIsSuccess(false);
        }
        return jsonMsgDto;
    }
}
